import Vue from 'vue'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
import GlsxVueCommon from 'glsx-vue-common'
Vue.use(GlsxVueCommon)
Vue.use(ElementUI)
var mixin = {
  mounted() {
    const _this = this
    const theme = new this.$Theme()
    const connection = this.$Penpal.connectToParent({
      methods: {
        setTheme(color) {
          theme.change(color)
        },
        height() {
          return document.documentElement.clientHeight || document.body.clientHeight // document.height || document.body.offsetHeight //
        },
        setResources(resources) {
          _this.$set_session_config(resources)
        }
      }
    })
    connection.promise.then(parent => {
      _this.$parent_iframe = parent
      parent.getResources().then(data => {
        const { resources, color } = data
        _this.$set_session_config(resources)
        theme.change(color)
      })
    })
  }
}
const render = App => {
  new Vue({
    el: '#app',
    mixins: [mixin],
    render: h => h(App)
  })
}
export default { render }

